package com.daervin.svc.common.exception;

import com.daervin.svc.common.dto.ResponseVO;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * Created by daervin on 2023/8/26
 */
@RestControllerAdvice
public class ExceptionAspect {

    @ExceptionHandler(Exception.class)
    public ResponseVO exceptionHandler(Exception e) {
        return ResponseVO.error(ErrorCode.SYSTEM_ERROR.getCode(), ErrorCode.SYSTEM_ERROR.getMessage());
    }

    @ExceptionHandler(CommonException.class)
    public ResponseVO commonExceptionHandler(CommonException e) {
        return ResponseVO.error(e.getErrorCode().getCode(), e.getMessage());
    }
}
